/**
 * Created by judasnow on 20/06/2017.
 */

import {
    SHOW_LOADING,
    HIDE_LOADING
} from '../mutations'
import * as types from '../mutations'

const state = {
    text: '',
    isVisible: false,
};

const actions = {
    showLoading ({ commit }, msg) {
        commit(types.SHOW_LOADING, msg)
    },
    hideLoading ({ commit }) {
        commit(types.HIDE_LOADING)
    }
};

const mutations = {
    [SHOW_LOADING] (state, text) {
        state.text = text;
        state.isVisible = true;
    },
    [HIDE_LOADING] (state) {
        state.isVisible = false
    }
};

export default {
    state,
    actions,
    mutations
}